<template>
  <div class="">
    <van-nav-bar
      @click-left="$router.back()"
      left-arrow
      title="管理员详情"
      fixed
    ></van-nav-bar>
    <h3 class="h3">
      <img src="../../assets/images/detail/head.png" alt="" />
      客户统计
    </h3>
    <header>
      <div class="item">
        <div class="left">
          <img src="../../assets/images/admin/detail1.png" alt="" />
        </div>
        <div class="right">
          <h4>管理员客户数</h4>
          <p>
            <strong>{{ ingo.clientCount || 0 }}</strong
            >人
          </p>
        </div>
      </div>
      <div class="item">
        <div class="left">
          <img src="../../assets/images/admin/detail2.png" alt="" />
        </div>
        <div class="right">
          <h4>今日新增客户</h4>
          <p>
            <strong>{{ ingo.todayCount || 0 }}</strong
            >人
          </p>
        </div>
      </div>
    </header>
    <div class="info">
      <div class="item">
        <h4>总转发数</h4>
        <p>
          {{ ingo.sumTransmit || 0 }}
          <span>篇</span>
        </p>
      </div>
      <div class="item">
        <h4>总阅读数</h4>
        <p>{{ ingo.sumRead || 0 }} <span>篇</span></p>
      </div>
      <div class="item">
        <h4>今日转发</h4>
        <p>{{ ingo.todayTransmit || 0 }}<span>篇</span></p>
      </div>
      <div class="item">
        <h4>今日阅读</h4>
        <p>{{ ingo.todayRead || 0 }}<span>篇</span></p>
      </div>
    </div>
    <main>
      <h3 class="h3">
        <img src="../../assets/images/detail/head.png" alt="" />
        客户列表
      </h3>
      <div class="content" v-if="clientArr.length !== 0">
        <van-list
          v-model="loading"
          :finished="finished"
          :immediate-check="false"
          @load="onLoad"
        >
          <div class="item" v-for="(item, index) in clientArr" :key="index">
            <div class="left">
              <img :src="$publicObj.urlImg(item.image)" alt="" />
            </div>
            <div class="right">
              <h3>{{ item.nickname }}</h3>
              <div class="foot">
                <p>{{ item.gmtCreate.slice(0, 11) }}</p>
                <div class="rights">
                  <span>来自</span>
                  <span v-if="item.tableType == 1">文章</span>
                  <span v-else-if="item.tableType == 3">海报</span>
                  <span v-else-if="item.tableType == 4">视频</span>
                  <span v-else-if="item.tableType == 15">招聘</span>
                </div>
              </div>
            </div>
          </div>
        </van-list>
      </div>
      <van-empty description="暂无客户" v-else />
    </main>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      clientArr: [],
      ingo: {},
      loading: false, //加载状态
      finished: false, //完成
      page: 1, //页数
      limit: 8, //条数
      totalPage: 100, //总页数
    };
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {
    document.querySelector("html").style.backgroundColor = "#f3f5f7";
    document.querySelector("body").style.backgroundColor = "#f3f5f7";
  },
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {
    this.getAdministratorDetails();
  },
  methods: {
    //触底下一页
    onLoad() {
      if (this.page >= this.totalPage) {
        this.finished = true;
        return;
      }
      this.page++;
      this.getAdministratorDetails();
      // 加载状态结束
      this.loading = false;
    },
    //获取客户列表
    async getAdministratorDetails() {
      let obj = {
        page: this.page,
        limit: this.limit,
        id: this.$route.query.id,
      };
      let res = await this.$api.administratorDetails(obj);
      if (res.code != 0) return;
      //判断是否是第一页
      if (this.page == 1) {
        this.clientArr = res.data.list || [];
      } else {
        this.clientArr.push(...res.data.list);
      }
      this.totalPage = res.data.totalPage;
      this.ingo = res.ingo;
    },
  },
};
</script>
<style scoped lang="less">
/* @import url(); 引入css类 */
.h3 {
  padding-top: 66px;
  font-size: 16px;
  font-weight: 700;
  color: #333333;
  letter-spacing: 1px;
  margin: 0 0 10px 15px;
  img {
    width: 4px;
    height: 15px;
    margin-right: 5px;
  }
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 15px;
  background-color: #fff;
  border-radius: 4px;
  padding: 20px 0 17px;
  .item {
    display: flex;
    flex: 1;
    justify-content: center;
    align-items: center;
    &:nth-of-type(n + 2) {
      border-left: 1px dashed #969798;
    }
    .left {
      display: flex;
      justify-content: center;
      align-items: center;
      img {
        width: 42px;
        height: 42px;
        margin-right: 11px;
      }
    }
    .right {
      h4 {
        font-size: 11px;
        color: #999999;
        margin-bottom: 4px;
      }
      p {
        font-size: 10px;
        color: #2d2d2d;
        letter-spacing: 1px;
        strong {
          font-size: 16px;
        }
      }
    }
  }
}
.info {
  display: flex;
  justify-content: space-between;
  margin: 15px;
  .item {
    width: 82px;
    height: 47px;
    border-radius: 5px;
    color: #fff;
    border-radius: 10px;
    background: url("../../assets/images/detail/bg1.png") no-repeat;
    background-size: 100%;
    &:nth-of-type(2) {
      background: url("../../assets/images/detail/bg2.png") no-repeat;
      background-size: 100%;
    }
    &:nth-of-type(3) {
      background: url("../../assets/images/detail/bg3.png") no-repeat;
      background-size: 100%;
    }
    &:nth-of-type(4) {
      background: url("../../assets/images/admin/bg4.png") no-repeat;
      background-size: 100%;
    }

    h4 {
      font-size: 10px;
      padding: 6px 0 3px;
      text-align: center;
    }
    p {
      font-size: 12px;
      font-weight: 700;
      display: flex;
      justify-content: center;
      align-items: center;
      span {
        font-size: 8px;
        font-weight: normal;
      }
    }
  }
}
.poster_type {
  padding: 12px 100px;

  background-color: #fff;
  ul {
    display: -webkit-flex;
    display: flex;
    justify-content: space-between;
    li {
      font-size: 16px;
      color: #666;
      display: -webkit-flex;
      display: flex;
      justify-content: center;
      position: relative;
      align-items: center;
      padding: 5px 0;
      i {
        width: 28px;
        height: 3px;
        border-radius: 3px;
        position: absolute;
        bottom: -5px;
      }
    }
    .active {
      font-weight: 700;
      color: #000;
      i {
        background-color: #0264d1;
      }
    }
  }
}
main {
  padding: 0 15px;
  background-color: #f3f5f7;
  .h3 {
    margin: 20px 0 10px;
    font-size: 16px;
    font-weight: 700;
    color: #333333;
    letter-spacing: 1px;
    padding-top: 0;
    img {
      width: 4px;
      height: 15px;
      margin-right: 5px;
    }
  }
  .content {
    background: #ffffff;
    box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.08);
    height: calc(100vh - 300px);
    overflow-y: scroll;
    .item {
      display: flex;
      align-items: center;
      padding: 15px;
      border-bottom: 1px solid #f5f6f8;
      .left {
        img {
          width: 53px;
          height: 53px;
          border-radius: 50%;
        }
      }
      .right {
        margin-left: 12px;
        flex: 1;
        height: 53px;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        h3 {
          margin: 0;
          font-weight: 400;
        }
        .foot {
          display: flex;
          align-items: center;
          justify-content: space-between;
          p {
            font-size: 10px;
            color: #999999;
          }
          .rights {
            font-size: 12px;
            color: #999999;
            span {
              margin-right: 9px;
              &:last-of-type {
                padding-left: 10px;
                border-left: 1px solid #999999;
                color: #666666;
              }
            }
          }
        }
      }
    }
  }
}
</style>
